<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>箭头函数</title>
</head>
<body>
  <script>
    /**
     * 语法简洁
     * 隐式返回
     * 命名函数改造
    */
    // 1. 语法简洁
    (() => {
      const arr1 = [1, 2, 3];
      arr1.forEach(function (a) {
        console.log(a);
      })
    })();

    (() => {
      const arr1 = [1, 2, 3];
      arr1.forEach(a => {
        console.log(a);
      })
    })();

    // 2. 隐式返回
    (() => {
      const arr2 = [4, 5, 6];
      const findItem = arr2.find(a => a > 3);
      console.log('findItem', findItem);
    })();

    // 3. 命名函数改造
    function arr3 () {
      console.log('arr3');
    }
    const arr4 = () => {
      console.log('arr4');
    }
    arr3();
    arr4();
  </script>
</body>
</html>